package com.breakfast.fun.data.entity.user.coupon;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by yukai on 2016/11/3.
 */

public class Coupon {

    /**
     * version : 1.0
     * success : true
     * msg : 查询成功
     * data : [{"id":9,"userId":12384,"couponId":2,"status":1,"createTime":"2016-11-03 11:38:19","isTimeout":1,"value":5,"conditions":10,"name":"测试优惠券","rule":"1.我是帅哥|2.我是帅哥","bettwenTime":"2016-11-03~2016-11-05"},{"id":10,"userId":12384,"couponId":3,"status":1,"createTime":"2016-11-03 11:38:28","isTimeout":1,"value":3,"conditions":5,"name":"余凯优惠券","rule":"1.我是帅哥","bettwenTime":"2016-11-03~2016-11-05"}]
     */

    private String version;
    private boolean success;
    private String msg;
    /**
     * id : 9
     * userId : 12384
     * couponId : 2
     * status : 1
     * createTime : 2016-11-03 11:38:19
     * isTimeout : 1
     * value : 5
     * conditions : 10
     * name : 测试优惠券
     * rule : 1.我是帅哥|2.我是帅哥
     * bettwenTime : 2016-11-03~2016-11-05
     */

    private List<CouponData> data;

    public static Coupon objectFromData(String str) {

        return new Gson().fromJson(str, Coupon.class);
    }

    public static List<Coupon> arrayCouponFromData(String str) {

        Type listType = new TypeToken<ArrayList<Coupon>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List<CouponData> getData() {
        return data;
    }

    public void setData(List<CouponData> data) {
        this.data = data;
    }

    public static class CouponData implements Serializable {
        private int id;
        private int userId;
        private int couponId;
        private int status;
        private String createTime;
        private int deadTime;
        private int isTimeout;
        private float value;
        private BigDecimal conditions;
        private String name;
        private String rule;
        private String bettwenTime;

        public static CouponData objectFromData(String str) {

            return new Gson().fromJson(str, CouponData.class);
        }

        public static List<CouponData> arrayDataBeanFromData(String str) {

            Type listType = new TypeToken<ArrayList<CouponData>>() {
            }.getType();

            return new Gson().fromJson(str, listType);
        }

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public int getUserId() {
            return userId;
        }

        public void setUserId(int userId) {
            this.userId = userId;
        }

        public int getCouponId() {
            return couponId;
        }

        public void setCouponId(int couponId) {
            this.couponId = couponId;
        }

        public int getStatus() {
            return status;
        }

        public void setStatus(int status) {
            this.status = status;
        }

        public String getCreateTime() {
            return createTime;
        }

        public void setCreateTime(String createTime) {
            this.createTime = createTime;
        }

        public int getDeadTime() {
            return deadTime;
        }

        public void setDeadTime(int deadTime) {
            this.deadTime = deadTime;
        }

        public int getIsTimeout() {
            return isTimeout;
        }

        public void setIsTimeout(int isTimeout) {
            this.isTimeout = isTimeout;
        }

        public float getValue() {
            return value;
        }

        public void setValue(float value) {
            this.value = value;
        }

        public BigDecimal getConditions() {
            return conditions;
        }

        public void setConditions(BigDecimal conditions) {
            this.conditions = conditions;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getRule() {
            return rule;
        }

        public void setRule(String rule) {
            this.rule = rule;
        }

        public String getBettwenTime() {
            return bettwenTime;
        }

        public void setBettwenTime(String bettwenTime) {
            this.bettwenTime = bettwenTime;
        }
    }
}
